﻿// C# Example
// Builds an asset bundle from the selected folder in the project view.
// Bare in mind that this script doesnt track dependencies nor is recursive
//在项目视图从选择的文件夹生成资源包
//记住，这个脚本不跟踪依赖关系，也不是递归
using UnityEngine;
using UnityEditor;
using System.IO;
namespace QPTools
{
    public class BuildAssetBundlesFromDirectory
    {
        //在Unity编辑器中添加菜单  
        //[MenuItem("Assets/Build AssetBundle From Selection")]  
        static void ExportResourceRGB2()
        {
            // 打开保存面板，获得用户选择的路径  
            string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "assetbundle");

            if (path.Length != 0)
            {
                // 选择的要保存的对象  
                Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
                //打包  
                //BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.Android);  
            }
        }
    }
}